Hi folks - I’ve been able to successfully create incidents in the developer V2 API reference site but then same json payload running within my python script generates a “2001 error”. I guess HAL is not happy
can someone see why this code segment would cause that issue ? (my Token is correct and gets applied properly within the developer web site and gets passed into the header correctly in my code below)
import requests
import os
token=os.environ[“PD_API_TEST”]
headerstr = {‘Content-Type’: ‘application/json’, ‘From’: ‘jcalcada@pagerduty.com’, ‘Authorization’: ‘Token token={token}’, ‘Accept’: ‘application/vnd.pagerduty+json;version=2’}
urlstr=“https://api.pagerduty.com/incidents”
payloadhead = ‘{\n"incident": { \n “type”: “trigger”,\n’
servicestr =’ “service”: { \n “id”: “P2NMIJW”,\n “type”: “service_reference”\n },\n’
summarystr = ’ “title”: “this is title #1”,\n’
detailstr = ’ “body”: { \n “type”: “incident_body”, \n “details”: “This is detail info” \n }’
payload = payloadhead + summarystr + servicestr + detailstr + ’ \n } \n}’
r = requests.post(urlstr, json=payload, headers=headerstr)
r.raise_for_status
print(f"{payload}")
print(f"{r.json()}")